<html>
<head>
    <meta charset="UTF-8">
    <title>activeMQ 消息提醒示例</title>
    <link rel="stylesheet" type="text/css" href="default.css">
    <link rel="stylesheet" type="text/css" href="jquery.notify.css">

    <script type="text/javascript" src="stomp.js"></script>
    <script type="text/javascript" src="jquery.min.js"></script>
    <script type="text/javascript" src="jquery.notify.js"></script>
</head>
<script type="text/javascript">
    $(function () {
        $.notifySetup({sound: 'jquery.notify.wav'});

        //创建客户端
      //  var client = Stomp.client("ws://localhost:61614/");
        var client = Stomp.client("ws://192.168.199.115:61614/");
        //定义连接成功回调函数
        var onConnect = function () {
            //订阅消息队列
            client.subscribe("/topic/shopping-discount", function (message) {
                //弹出业务消息提醒，并停留10秒
                $("<p>" + message.body + "</p>").notify({stay: 10000});
            });

        };
        //定义错误时回调函数
        var onError = function (msg) {
            $("<p>服务器错误：" + msg + "</p>").notify("error");
        };
        //连接服务器
        client.connect("guest", "guest", onConnect, onError);
        client.heartbeat.incoming = 5000;
        client.heartbeat.outgoing = 5000;

    });

</script>

<body>

</body>
</html>